package com.zut.dao;

import com.zut.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface UserDao {

    // 根据电话号码跟密码来验证登录
    @Select("select * from `user` where phone=#{phone} and password=#{password}")
    User selectByNameAndPassword(@Param("phone") String phone, @Param("password") String password);

    @Insert("insert into `user`(phone,username,password) values(#{phone},#{username},#{password}) ")
    // 注册用户
    Integer addUser(@Param("phone") String phone, @Param("username") String username,@Param("password") String password);

    // 根据手机号来查询用户
    @Select("select * from `user` where phone=#{phone}")
    User selectUserByPhone(@Param("phone") String phone);

    // 用户认证
    @Update("update `user` set realname=#{realname},idcard=#{idcard} where phone=#{phone}")
    int addAuthentication(User user);

    // 根据id查询用户
    @Select("select * from `user` where id=#{id}")
    User selectUserById(@Param("id") Integer id);
}
